package hc.bre.log

import org.springframework.data.mongodb.core.mapping.Document


@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true, includePackage = false)
class RuleLog{
	String ruleClass;
	Object result;
	String status; //completed | exception;
	List<RuleLog> details;
	
	@org.springframework.data.annotation.Transient
	long nanoTimeStarted =System.nanoTime();
	long elapsedNanoSeconds;
	
	RuleLog(Closure rule) {
		ruleClass = rule.getClass().getName();
	}

	void setNanoTimeEnded(long nanoTimeEnded)
	{
		this.elapsedNanoSeconds = nanoTimeEnded  - nanoTimeStarted;
	}
		
	void addLogIntoDetails(RuleLog log)
	{
		if(this.details==null) this.details = [];
		this.details.add(log);
	}
}
